﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<%= TempData["Message"]%>
    <div id="cactionbutton">
        <button type="button" id="btnRefesh" title="Refesh" class="button refresh">Làm tươi</button> 
        <button type="button" id="btnDelete" title="Delete" class="button delete">Xóa</button>
        <button type="button" id="btnAddNew" title="Add New" class="button addnew">Tạo mới</button>
    </div>
    <div id="cfilter">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <%=Html.AutoCompleteTextBox("txtKeyword", "Nhập mã số hoặc tiêu đề", "News", true)%>
                        
                    </td>
                    <td>
                        <%=Html.AutoCompleteTextBox("txtAuthor", "Nhập tác giả", "Author", true)%>
                    </td>
                    <td>
                        Ngày tạo từ
                    </td>
                    <td>
                        <%=Html.DatePicker("FromDate")%>
                        
                    </td>
                    <td>
                        Đến
                    </td>
                    <td>
                        <%=Html.DatePicker("ToDate")%>
                    </td>
                    <td>
                        <button type="button" id="btnFilter" title="Filter" class="button filter">Filter</button>
                        
                    </td>
                </tr>
            </table>
    </div>
    <div class="clist">
        <table id="list" class="scroll">
        </table>
        <div id="pager" class="scroll" style="text-align: center;">
        </div>
    </div>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="PageTitle" runat="server">
    Quản lý tin tức
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
 <script type="text/javascript">
     jQuery(document).ready(function () {
         JS_LIB.onEnterKeyword();
         // refresh button
         $("#btnRefesh").click(function () {
             window.location = "/Administration/News";
         });
         //Add New
         $("#btnAddNew").click(function () {
             window.location = "/Administration/News/Create";
         });
         // filter button
         $("#btnFilter").click(function () {
             var p_text = encodeURIComponent($('#txtKeyword').val());
             if (p_text == encodeURIComponent('Nhập mã số hoặc tiêu đề')) {
                 p_text = "";
             }
             var p_author = encodeURIComponent($('#txtAuthor').val());
             if (p_author == encodeURIComponent('Nhập tác giả')) {
                 p_author = "";
             }
             $('#list').setGridParam({ url: '/Administration/News/GetListJQGrid/?p_text=' + p_text + '&p_author=' + p_author +
                 '&p_fromdate=' + $('#FromDate').val() + '&p_todate=' + $('#ToDate').val()
             }).trigger('reloadGrid');
         });
         // delete button           
         $("#btnDelete").click(function () {
             JS_LIB.deletes('#list', 'ID', '/Administration/News/DeleteList');
         });
     });
    </script>
    <%  
        TSV.Library.Controls.GridViewControls grid = new TSV.Library.Controls.GridViewControls();
        grid.Width = 1024;
                
        string[] colNames = { "ID","Hình ảnh", "Tiêu đề", "Chú thích", "Ngày tạo", "Tác giả", "Hành động"};
        string[] colModels = {  "{ name: 'ID', index: 'ID', align: 'center', width: 50,hidden: true}",
                                "{ name: 'Image', index: 'Image', align: 'center', width: 100, sortable: false}",
                                "{ name: 'Title', index: 'Title', align: 'left', width: 150, sortable: true }",
                                "{ name: 'Description', index: 'Description', align: 'left', width: 100, sortable: true }",
                                "{ name: 'PostedDate', index: 'PostedDate', align: 'center', width: 60, sortable: true }",
                                "{ name: 'Author', index: 'Author', align: 'center', width: 55, sortable: true }",
                                "{ name: 'Action', index: 'Action', align: 'center', width: 40, sortable: false }"
                            };

        Response.Write(grid.ShowGrid("/Administration/News/GetListJQGrid/", colNames, colModels));
    %>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="ModuleName" runat="server">
Quản lý tin tức
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="FunctionTitle" runat="server">
Quản lý tin tức
</asp:Content>

<asp:Content ID="Content6" ContentPlaceHolderID="LoginRoles" runat="server">
</asp:Content>
